{% extends "base.html" %}
{% block title %}{% endblock %}
{% block content %}
<br>
<div  class="layui-body" style="left:0px">
    <br>
    <div id="all" style="height:600px;"></div>
        <div id="avg_response_time" style="height:400px;"></div>
        <div id="list_current_rps" style="height:400px;"></div>
    <br>


</div>
<script type="text/javascript">
layui.use(['table','code'], function(){
          var table = layui.table
          ,form = layui.form;
          var $= layui.jquery;
          var loading = layer.load();
          task_name = layui.data('test').task_name;

          $.ajax({
                        //发出请求
                        type:"GET",
                        url:"/result/list/png",
                        contentType: 'application/json; charset=utf-8',
                        dataType:"json",
                        data:{"task_name":task_name},
                        success: function(result){
                            var avg_myChart = echarts.init(document.getElementById('avg_response_time'));
                            avg_response_time_option = {
                                 title: {
                                    text: "avg_response_time",

                                    show : true
                                },
                                xAxis: {
                                    type: 'category',
                                    data:result.list_last_time,
                                    axisLabel: {
                                        interval:0,
                                        rotate:15
                                    },
                                    boundaryGap:true
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                series: [{
                                    data: result.list_avg_response_time,
                                    type: 'line',
                                    itemStyle : { normal: {label : {show: true}}}
                                }]
                            };

                            avg_myChart.setOption(avg_response_time_option);

                            var rps_myChart = echarts.init(document.getElementById('list_current_rps'));

                            rps_option = {
                                 title: {
                                    text: "current_rps",

                                    show : true
                                },
                                xAxis: {
                                    type: 'category',
                                    data:result.list_last_time,
                                    axisLabel: {
                                        interval:0,
                                        rotate:15
                                    },
                                    boundaryGap:true
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                series: [{
                                    data: result.list_current_rps,
                                    type: 'line',
                                    itemStyle : { normal: {label : {show: true}}}
                                }]
                            };
                            rps_myChart.setOption(rps_option);


                            var all_myChart = echarts.init(document.getElementById('all'));

                            all_option = {
                                        title: {
                                            text: '常用趋势图',

                                            show : true
                                        },
                                        tooltip: {
                                            trigger: 'axis'
                                        },
                                        legend: {
                                            data: ['avg_response_time', 'current_rps', 'user_count', 'num_requests', 'num_failures']
                                        },
                                        grid: {
                                            left: '3%',
                                            right: '4%',
                                            bottom: '3%',
                                            containLabel: true
                                        },
                                        toolbox: {
                                            feature: {
                                                saveAsImage: {}
                                            }
                                        },
                                        xAxis: {
                                            type: 'category',
                                            axisLabel: {
                                                interval:0,
                                                rotate:15
                                            },
                                            boundaryGap:true,

                                            data: result.list_last_time
                                        },
                                        yAxis: {
                                            type: 'value'
                                        },
                                        series: [
                                            {
                                                name: 'avg_response_time',
                                                type: 'line',
                                                stack: '总量',
                                                data: result.list_avg_response_time
                                            },
                                            {
                                                name: 'current_rps',
                                                type: 'line',
                                                stack: '总量',
                                                data:  result.list_current_rps
                                            },
                                            {
                                                name: 'user_count',
                                                type: 'line',
                                                stack: '总量',
                                                data: result.list_user_count
                                            },
                                            {
                                                name: 'num_requests',
                                                type: 'line',
                                                stack: '总量',
                                                data:result.list_num_requests
                                            },
                                            {
                                                name: 'num_failures',
                                                type: 'line',
                                                stack: '总量',
                                                data: result.list_num_failures
                                            }
                                        ]
                                    };

                            all_myChart.setOption(all_option);

                            layer.close(loading);


                        }
            });



});
</script>
{% endblock %}